﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TRPOP.Cache
{
    /// <summary>
    /// 缓存操作接口
    /// </summary>
    public interface ICache
    {
        /// <summary>
        /// 增加一个缓存对象
        /// </summary>
        /// <param name="strKey">主键</param>
        /// <param name="objValue">cache值</param>
        /// <param name="durationSecond">以秒为单位</param>
        /// <returns></returns>
        bool Save(string strKey, object objValue, double durationSecond);

        /// <summary>
        /// 判断缓存对象是否存在
        /// </summary>
        /// <param name="strKey">主键</param>
        /// <returns></returns>
        bool IsExist(string strKey);

        /// <summary>
        /// 读取缓存对象
        /// </summary>
        /// <param name="strKey">主键</param>
        /// <returns></returns>
        object Read(string strKey);

        /// <summary>
        /// 删除缓存对象
        /// </summary>
        /// <param name="strKey"></param>
        void Remove(string strKey);

        /// <summary>
        /// 根据设置的正则表达式清除缓存对象
        /// </summary>
        /// <param name="pattern">正则表达式</param>
        void RemoveByRegexp(string pattern);

        /// <summary>
        /// 清除所有缓存对象
        /// </summary>
        void Clear();
    }
}
